<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <title>Select 选择器 | MyUI 4.x</title>
    <meta name="generator" content="VuePress 1.5.0">
    <link rel="icon" href="/my/favicon.ico">
    <script>
      var _hmt = _hmt || [];
      (function() {
        var hm = document.createElement("script");
        hm.src = "https://hm.baidu.com/hm.js?c4e5f73318b5cb0c389e3d9a05f831cc";
        var s = document.getElementsByTagName("script")[0];
        s.parentNode.insertBefore(hm, s);
      })();
    </script>
    <meta name="description" content="MyUI是美亚柏科旗下新德汇出品的Web前端一站式项目工程框架，专注于公检法行业中台系统快速搭建，框架已在多个项目实战检验。">
    <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate">
    <meta http-equiv="Pragma" content="no-cache">
    <meta http-equiv="Expires" content="0">
    <link rel="preload" href="/my/assets/css/0.styles.3b7da768.css" as="style"><link rel="preload" href="/my/assets/js/app.145deadf.js" as="script"><link rel="preload" href="/my/assets/js/546.c48d7d92.js" as="script"><link rel="preload" href="/my/assets/js/1310.d756e49e.js" as="script"><link rel="preload" href="/my/assets/js/974.ffa6c050.js" as="script">
    <link rel="stylesheet" href="/my/assets/css/0.styles.3b7da768.css">
  </head>
  <body>
    <div id="app" data-server-rendered="true"><div class="theme-container"><header class="navbar"><div class="sidebar-button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" viewBox="0 0 448 512" class="icon"><path fill="currentColor" d="M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z"></path></svg></div> <a href="/my/" class="home-link router-link-active"><img src="/my/img/logo.png" alt="MyUI 4.x" class="logo"> <span class="site-name can-hide">MyUI 4.x</span></a> <div class="links"><div class="search-box"><input aria-label="Search" autocomplete="off" spellcheck="false" value=""> <!----></div> <nav class="nav-links can-hide"><div class="nav-item"><a href="/my/guide/" class="nav-link">
  指南
</a></div><div class="nav-item"><a href="/my/ui/components/" class="nav-link">
  组件
</a></div><div class="nav-item"><a href="/my/ui/charts/" class="nav-link">
  图表
</a></div><div class="nav-item"><a href="/my/ui/map/" class="nav-link">
  地图
</a></div><div class="nav-item"><a href="/my/ui/go/" class="nav-link">
  关系图
</a></div><div class="nav-item"><a href="/my/ui/icon/" class="nav-link">
  图标
</a></div><div class="nav-item"><a href="/my/ui/pages/" class="nav-link">
  页面
</a></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="JSDoc" class="dropdown-title"><span class="title">JSDoc</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/my/api/components.html" class="nav-link">
  基础组件
</a></li><li class="dropdown-item"><!----> <a href="/my/api/utils.html" class="nav-link">
  工具函数
</a></li><li class="dropdown-item"><!----> <a href="/my/api/charts.html" class="nav-link">
  图表组件
</a></li><li class="dropdown-item"><!----> <a href="/my/api/map.html" class="nav-link">
  地图组件
</a></li></ul></div></div> <!----></nav></div></header> <div class="sidebar-mask"></div> <aside class="sidebar"><nav class="nav-links"><div class="nav-item"><a href="/my/guide/" class="nav-link">
  指南
</a></div><div class="nav-item"><a href="/my/ui/components/" class="nav-link">
  组件
</a></div><div class="nav-item"><a href="/my/ui/charts/" class="nav-link">
  图表
</a></div><div class="nav-item"><a href="/my/ui/map/" class="nav-link">
  地图
</a></div><div class="nav-item"><a href="/my/ui/go/" class="nav-link">
  关系图
</a></div><div class="nav-item"><a href="/my/ui/icon/" class="nav-link">
  图标
</a></div><div class="nav-item"><a href="/my/ui/pages/" class="nav-link">
  页面
</a></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="JSDoc" class="dropdown-title"><span class="title">JSDoc</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/my/api/components.html" class="nav-link">
  基础组件
</a></li><li class="dropdown-item"><!----> <a href="/my/api/utils.html" class="nav-link">
  工具函数
</a></li><li class="dropdown-item"><!----> <a href="/my/api/charts.html" class="nav-link">
  图表组件
</a></li><li class="dropdown-item"><!----> <a href="/my/api/map.html" class="nav-link">
  地图组件
</a></li></ul></div></div> <!----></nav>  <ul class="sidebar-links"><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>Basic</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading open"><span>Form</span> <span class="arrow down"></span></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/my/element/cascader.html" class="sidebar-link">Cascader 级联选择器</a></li><li><a href="/my/element/checkbox.html" class="sidebar-link">Checkbox 多选框</a></li><li><a href="/my/element/color-picker.html" class="sidebar-link">ColorPicker 颜色选择器</a></li><li><a href="/my/element/date-picker.html" class="sidebar-link">DatePicker 日期选择器</a></li><li><a href="/my/element/datetime-picker.html" class="sidebar-link">DateTimePicker 日期时间选择器</a></li><li><a href="/my/element/form.html" class="sidebar-link">Form 表单</a></li><li><a href="/my/element/input.html" class="sidebar-link">Input 输入框</a></li><li><a href="/my/element/input-number.html" class="sidebar-link">InputNumber 计数器</a></li><li><a href="/my/element/radio.html" class="sidebar-link">Radio 单选框</a></li><li><a href="/my/element/rate.html" class="sidebar-link">Rate 评分</a></li><li><a href="/my/element/select.html" aria-current="page" class="active sidebar-link">Select 选择器</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header"><a href="/my/element/select.html#基础用法" class="sidebar-link">基础用法</a></li><li class="sidebar-sub-header"><a href="/my/element/select.html#有禁用选项" class="sidebar-link">有禁用选项</a></li><li class="sidebar-sub-header"><a href="/my/element/select.html#禁用状态" class="sidebar-link">禁用状态</a></li><li class="sidebar-sub-header"><a href="/my/element/select.html#可清空单选" class="sidebar-link">可清空单选</a></li><li class="sidebar-sub-header"><a href="/my/element/select.html#基础多选" class="sidebar-link">基础多选</a></li><li class="sidebar-sub-header"><a href="/my/element/select.html#自定义模板" class="sidebar-link">自定义模板</a></li><li class="sidebar-sub-header"><a href="/my/element/select.html#分组" class="sidebar-link">分组</a></li><li class="sidebar-sub-header"><a href="/my/element/select.html#可搜索" class="sidebar-link">可搜索</a></li><li class="sidebar-sub-header"><a href="/my/element/select.html#远程搜索" class="sidebar-link">远程搜索</a></li><li class="sidebar-sub-header"><a href="/my/element/select.html#创建条目" class="sidebar-link">创建条目</a></li><li class="sidebar-sub-header"><a href="/my/element/select.html#select-attributes" class="sidebar-link">Select Attributes</a></li><li class="sidebar-sub-header"><a href="/my/element/select.html#select-events" class="sidebar-link">Select Events</a></li><li class="sidebar-sub-header"><a href="/my/element/select.html#select-slots" class="sidebar-link">Select Slots</a></li><li class="sidebar-sub-header"><a href="/my/element/select.html#option-group-attributes" class="sidebar-link">Option Group Attributes</a></li><li class="sidebar-sub-header"><a href="/my/element/select.html#option-attributes" class="sidebar-link">Option Attributes</a></li><li class="sidebar-sub-header"><a href="/my/element/select.html#methods" class="sidebar-link">Methods</a></li></ul></li><li><a href="/my/element/slider.html" class="sidebar-link">Slider 滑块</a></li><li><a href="/my/element/switch.html" class="sidebar-link">Switch 开关</a></li><li><a href="/my/element/time-picker.html" class="sidebar-link">TimePicker 时间选择器</a></li><li><a href="/my/element/transfer.html" class="sidebar-link">Transfer 穿梭框</a></li><li><a href="/my/element/upload.html" class="sidebar-link">Upload 上传</a></li></ul></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>Data</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>Notice</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>Navigation</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>Others</span> <span class="arrow right"></span></p> <!----></section></li></ul> </aside> <main class="page"> <div class="theme-default-content content__default"><h1 id="select-选择器"><a href="#select-选择器" class="header-anchor">#</a> Select 选择器</h1> <p>当选项过多时，使用下拉菜单展示并选择内容。</p> <h2 id="基础用法"><a href="#基础用法" class="header-anchor">#</a> 基础用法</h2> <p>适用广泛的基础单选</p> <!----><h2 id="有禁用选项"><a href="#有禁用选项" class="header-anchor">#</a> 有禁用选项</h2> <!----><h2 id="禁用状态"><a href="#禁用状态" class="header-anchor">#</a> 禁用状态</h2> <p>选择器不可用状态</p> <!----><h2 id="可清空单选"><a href="#可清空单选" class="header-anchor">#</a> 可清空单选</h2> <p>包含清空按钮，可将选择器清空为初始状态</p> <!----><h2 id="基础多选"><a href="#基础多选" class="header-anchor">#</a> 基础多选</h2> <p>适用性较广的基础多选，用 Tag 展示已选项</p> <!----><h2 id="自定义模板"><a href="#自定义模板" class="header-anchor">#</a> 自定义模板</h2> <p>可以自定义备选项</p> <!----><h2 id="分组"><a href="#分组" class="header-anchor">#</a> 分组</h2> <p>备选项进行分组展示</p> <!----><h2 id="可搜索"><a href="#可搜索" class="header-anchor">#</a> 可搜索</h2> <p>可以利用搜索功能快速查找选项</p> <!----><h2 id="远程搜索"><a href="#远程搜索" class="header-anchor">#</a> 远程搜索</h2> <p>从服务器搜索数据，输入关键字进行查找</p> <!----><h2 id="创建条目"><a href="#创建条目" class="header-anchor">#</a> 创建条目</h2> <p>可以创建并选中选项中不存在的条目</p> <!----><div class="custom-block tip"><p class="custom-block-title">TIP</p> <p>如果 Select 的绑定值为对象类型，请务必指定 <code>value-key</code> 作为它的唯一性标识。</p></div> <h2 id="select-attributes"><a href="#select-attributes" class="header-anchor">#</a> Select Attributes</h2> <table><thead><tr><th>参数</th> <th>说明</th> <th>类型</th> <th>可选值</th> <th>默认值</th></tr></thead> <tbody><tr><td>value / v-model</td> <td>绑定值</td> <td>boolean / string / number</td> <td>—</td> <td>—</td></tr> <tr><td>multiple</td> <td>是否多选</td> <td>boolean</td> <td>—</td> <td>false</td></tr> <tr><td>disabled</td> <td>是否禁用</td> <td>boolean</td> <td>—</td> <td>false</td></tr> <tr><td>value-key</td> <td>作为 value 唯一标识的键名，绑定值为对象类型时必填</td> <td>string</td> <td>—</td> <td>value</td></tr> <tr><td>size</td> <td>输入框尺寸</td> <td>string</td> <td>medium/small/mini</td> <td>—</td></tr> <tr><td>clearable</td> <td>是否可以清空选项</td> <td>boolean</td> <td>—</td> <td>false</td></tr> <tr><td>collapse-tags</td> <td>多选时是否将选中值按文字的形式展示</td> <td>boolean</td> <td>—</td> <td>false</td></tr> <tr><td>multiple-limit</td> <td>多选时用户最多可以选择的项目数，为 0 则不限制</td> <td>number</td> <td>—</td> <td>0</td></tr> <tr><td>name</td> <td>select input 的 name 属性</td> <td>string</td> <td>—</td> <td>—</td></tr> <tr><td>autocomplete</td> <td>select input 的 autocomplete 属性</td> <td>string</td> <td>—</td> <td>off</td></tr> <tr><td>auto-complete</td> <td>下个主版本弃用</td> <td>string</td> <td>—</td> <td>off</td></tr> <tr><td>placeholder</td> <td>占位符</td> <td>string</td> <td>—</td> <td>请选择</td></tr> <tr><td>filterable</td> <td>是否可搜索</td> <td>boolean</td> <td>—</td> <td>false</td></tr> <tr><td>allow-create</td> <td>是否允许用户创建新条目，需配合 <code>filterable</code> 使用</td> <td>boolean</td> <td>—</td> <td>false</td></tr> <tr><td>filter-method</td> <td>自定义搜索方法</td> <td>function</td> <td>—</td> <td>—</td></tr> <tr><td>remote</td> <td>是否为远程搜索</td> <td>boolean</td> <td>—</td> <td>false</td></tr> <tr><td>remote-method</td> <td>远程搜索方法</td> <td>function</td> <td>—</td> <td>—</td></tr> <tr><td>loading</td> <td>是否正在从远程获取数据</td> <td>boolean</td> <td>—</td> <td>false</td></tr> <tr><td>loading-text</td> <td>远程加载时显示的文字</td> <td>string</td> <td>—</td> <td>加载中</td></tr> <tr><td>no-match-text</td> <td>搜索条件无匹配时显示的文字，也可以使用<code>slot=&quot;empty&quot;</code>设置</td> <td>string</td> <td>—</td> <td>无匹配数据</td></tr> <tr><td>no-data-text</td> <td>选项为空时显示的文字，也可以使用<code>slot=&quot;empty&quot;</code>设置</td> <td>string</td> <td>—</td> <td>无数据</td></tr> <tr><td>popper-class</td> <td>Select 下拉框的类名</td> <td>string</td> <td>—</td> <td>—</td></tr> <tr><td>reserve-keyword</td> <td>多选且可搜索时，是否在选中一个选项后保留当前的搜索关键词</td> <td>boolean</td> <td>—</td> <td>false</td></tr> <tr><td>default-first-option</td> <td>在输入框按下回车，选择第一个匹配项。需配合 <code>filterable</code> 或 <code>remote</code> 使用</td> <td>boolean</td> <td>-</td> <td>false</td></tr> <tr><td>popper-append-to-body</td> <td>是否将弹出框插入至 body 元素。在弹出框的定位出现问题时，可将该属性设置为 false</td> <td>boolean</td> <td>-</td> <td>true</td></tr> <tr><td>automatic-dropdown</td> <td>对于不可搜索的 Select，是否在输入框获得焦点后自动弹出选项菜单</td> <td>boolean</td> <td>-</td> <td>false</td></tr></tbody></table> <h2 id="select-events"><a href="#select-events" class="header-anchor">#</a> Select Events</h2> <table><thead><tr><th>事件名称</th> <th>说明</th> <th>回调参数</th></tr></thead> <tbody><tr><td>change</td> <td>选中值发生变化时触发</td> <td>目前的选中值</td></tr> <tr><td>visible-change</td> <td>下拉框出现/隐藏时触发</td> <td>出现则为 true，隐藏则为 false</td></tr> <tr><td>remove-tag</td> <td>多选模式下移除tag时触发</td> <td>移除的tag值</td></tr> <tr><td>clear</td> <td>可清空的单选模式下用户点击清空按钮时触发</td> <td>—</td></tr> <tr><td>blur</td> <td>当 input 失去焦点时触发</td> <td>(event: Event)</td></tr> <tr><td>focus</td> <td>当 input 获得焦点时触发</td> <td>(event: Event)</td></tr></tbody></table> <h2 id="select-slots"><a href="#select-slots" class="header-anchor">#</a> Select Slots</h2> <table><thead><tr><th>name</th> <th>说明</th></tr></thead> <tbody><tr><td>—</td> <td>Option 组件列表</td></tr> <tr><td>prefix</td> <td>Select 组件头部内容</td></tr> <tr><td>empty</td> <td>无选项时的列表</td></tr></tbody></table> <h2 id="option-group-attributes"><a href="#option-group-attributes" class="header-anchor">#</a> Option Group Attributes</h2> <table><thead><tr><th>参数</th> <th>说明</th> <th>类型</th> <th>可选值</th> <th>默认值</th></tr></thead> <tbody><tr><td>label</td> <td>分组的组名</td> <td>string</td> <td>—</td> <td>—</td></tr> <tr><td>disabled</td> <td>是否将该分组下所有选项置为禁用</td> <td>boolean</td> <td>—</td> <td>false</td></tr></tbody></table> <h2 id="option-attributes"><a href="#option-attributes" class="header-anchor">#</a> Option Attributes</h2> <table><thead><tr><th>参数</th> <th>说明</th> <th>类型</th> <th>可选值</th> <th>默认值</th></tr></thead> <tbody><tr><td>value</td> <td>选项的值</td> <td>string/number/object</td> <td>—</td> <td>—</td></tr> <tr><td>label</td> <td>选项的标签，若不设置则默认与 <code>value</code> 相同</td> <td>string/number</td> <td>—</td> <td>—</td></tr> <tr><td>disabled</td> <td>是否禁用该选项</td> <td>boolean</td> <td>—</td> <td>false</td></tr></tbody></table> <h2 id="methods"><a href="#methods" class="header-anchor">#</a> Methods</h2> <table><thead><tr><th>方法名</th> <th>说明</th> <th>参数</th></tr></thead> <tbody><tr><td>focus</td> <td>使 input 获取焦点</td> <td>-</td></tr> <tr><td>blur</td> <td>使 input 失去焦点，并隐藏下拉框</td> <td>-</td></tr></tbody></table></div> <footer class="page-edit"><!----> <!----></footer> <div class="page-nav"><p class="inner"><span class="prev">
      ←
      <a href="/my/element/rate.html" class="prev">
        Rate 评分
      </a></span> <span class="next"><a href="/my/element/slider.html">
        Slider 滑块
      </a>
      →
    </span></p></div> </main></div><div class="global-ui"></div></div>
    <script src="/my/assets/js/app.145deadf.js" defer></script><script src="/my/assets/js/546.c48d7d92.js" defer></script><script src="/my/assets/js/1310.d756e49e.js" defer></script><script src="/my/assets/js/974.ffa6c050.js" defer></script>
  </body>
</html>
